﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace COFE.Core.Actions
{
    /// <summary>
    /// Extension method for IReportProgress.
    /// </summary>
    public static class IWorkProgressExtension
    {
        public static bool ReportProgress(this IWorkProgress progress, int completed = -1, int total = -1, string file = null)
        {
            var args = new WorkProgressEventArgs(progress.Work, completed, total, file);
            progress.OnWorkProgress(args);
            return !args.Cancel;
        }

        public static bool ReportProgress(this IWorkProgress progress, int completed, int total)
        {
            return progress.ReportProgress(completed, total, null);
        }

        public static bool ReportProgress(this IWorkProgress progress, string file)
        {
            return progress.ReportProgress(-1, -1, file);
        }

        public static bool ReportMessage(this IWorkProgress progress, string message)
        {
            var args = new WorkMessageEventArgs(progress.Work, message);
            progress.OnWorkMessage(args);
            return !args.Cancel;
        }

    }
}
